/* 
以下为创建例子数据库的sql语句，如要测试，请到mysql客户端执行它，记得先创建数据库wz_data。
 */
/*
 DROP TABLE IF EXISTS `w_users`;
CREATE TABLE `w_users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `nickname` varchar(30) NOT NULL,
  `userid` varchar(10) NOT NULL,
  `passwd` varchar(8) NOT NULL,
  `age` int(3) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;


INSERT INTO `w_users` VALUES (1,'me','111','test123',20),(2,'he','222','test321',21),(3,'张傻','333','test333',22);
 */
let includes = ([
    "include/common.js",
]);

let Dbase = require("far-modules/dbase/dbase.js");
let gf = os.getGlobalThis();
let cf = gf["gameConf"];
let host = cf.dataBase.host;
let user = cf.dataBase.user;
let port = cf.dataBase.port;
let password = cf.dataBase.passwd;
let database = cf.dataBase.database;
let dbconn = new Dbase(host, user, password, port, database);
function create() {
    let me = thisObject();
    return me;
}

    function select(){
        return dbconn.table("w_users").where("userid","=","111").select();
    }
    function update(){
        return dbconn.table("w_users").assignment("nickname='she',age=20").where("nickname","=","he").update();
    }
    function insert(){
        return dbconn.table("w_users").fields("nickname,userid,passwd,age").values("'张傻','zwp111','test123',21").insert();
    }
    function del(){
        return dbconn.table("w_users").where("nickname","=","张傻").delete();
    }

module.exports = {select,
        update,
        insert,
        del
    }

